<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>第四步</title>
  </head>
  <body style="font-size: 50px">
    第四步 有⼀个停⻋⼩弟管理着两个停⻋场，他的停⻋策略是把⻋
    停到空位最少的停⻋场
    <br /><br /><br />
    打开控制台并 刷新 查看停车效果
  </body>
  <script src="../js/parkingLot.js"></script>
  <script src="../js/parkingAttendant.js"></script>
  <script>
    // 两个停车场
    const parkingLotA = new parkingLot({
      isFull: true,
      total: 10,
    });

    const parkingLotB = new parkingLot({
      isFull: false,
      total: 10,
    });

    // 停车场数组
    const parkingLotList = [parkingLotA, parkingLotB];

    // 停车场内的车辆状况数组
    const parkingLotCountList = [
      parkingLotA.getCarList(),
      parkingLotB.getCarList(),
    ];

    const res = parkingAttendant('lessSpaceFree', parkingLotCountList);

    console.table(parkingLotCountList);
    console.log(`第${res}个停车场空位最少`);

    res !== -1 && parkingLotList[res].parking("我");
    console.table(parkingLotCountList);
  </script>
</html>
